using System;
using System.Collections.Generic;

namespace Terra.Core.Common.Models.Common;

/// <summary>
/// 批量操作结果
/// </summary>
public class BatchOperationResult
{
    /// <summary>
    /// 成功数量
    /// </summary>
    public int SuccessCount { get; set; }

    /// <summary>
    /// 失败数量
    /// </summary>
    public int FailedCount { get; set; }

    /// <summary>
    /// 失败的ID列表
    /// </summary>
    public List<Guid> FailedIds { get; set; }

    /// <summary>
    /// 操作是否全部成功
    /// </summary>
    public bool IsAllSuccess => FailedCount == 0;

    /// <summary>
    /// 操作是否全部失败
    /// </summary>
    public bool IsAllFailed => SuccessCount == 0;

    /// <summary>
    /// 创建批量操作结果实例
    /// </summary>
    /// <param name="successCount">成功数量</param>
    /// <param name="failedCount">失败数量</param>
    /// <param name="failedIds">失败的ID列表</param>
    /// <returns>批量操作结果</returns>
    public static BatchOperationResult Create(int successCount, int failedCount, List<Guid> failedIds = null)
    {
        return new BatchOperationResult
        {
            SuccessCount = successCount,
            FailedCount = failedCount,
            FailedIds = failedIds ?? new List<Guid>()
        };
    }
}